/**
 * @file record.h
 * @copyright Copyright (C) 2015-2018 Alibaba Group Holding Limited
 */

#ifndef CX_RECORD_H
#define CX_RECORD_H

#include <stddef.h>
#include <stdint.h>
#include "cx_common.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_RECORD_NAME_LEN     128

/* 抓拍文件信息 */
typedef struct {
    char 	name[MAX_RECORD_NAME_LEN];
    uint32_t 	size;
	uint32_t 	time;
    cx_pic_type_e type;
} cx_vr_snapshot_info_t;

typedef struct {
    char  name[MAX_RECORD_NAME_LEN];
    uint32_t  size;
    uint32_t  begine_time;
    uint32_t  end_time;
    cx_video_encoding_type_e type;
} cx_vr_video_info_t;

/* 模块初始化参数 */
typedef struct {
    char *store_path;
    cx_record_video_save_type_e save_type;
} cx_record_param_t;

void *cx_vr_init(cx_record_param_t *param);

int cx_vr_deinit(void *hdl);

void *cx_record_get_handle(void);

int cx_vr_snapshot(void *hdl, int cam_id, uint8_t image_name[MAX_RECORD_NAME_LEN]);

int cx_vr_snapshot_search(void *hdl, uint32_t start_time, uint32_t stop_time, cx_vr_snapshot_info_t *images, int num);

int cx_vr_snapshot_get(void *hdl, uint8_t image_name[MAX_RECORD_NAME_LEN], uint8_t *image, uint32_t offset, int max_size);

int cx_vr_record_start(void *hdl, int cam_id, uint8_t video_name[128], uint32_t timeout);	/* 开始录像，返回录像名称，video_name出参 */

int cx_vr_record_stop(void *hdl);	/* 停止录像 */

int cx_vr_get_record_status(void *hdl);

int cx_vr_video_search(void *hdl, uint32_t start_time, uint32_t stop_time, cx_vr_video_info_t * info, int info_num);	/* 搜索时间段内的录像，返回录像名称 */

int cx_vr_video_open(void *hdl, uint8_t video_name[128]);	/* 打开录像文件，返回int句柄，video_name入参 */

int cx_vr_video_read(void *hdl, int fd, uint8_t *buf, int max_size);	/* 读取录像文件，返回读取大小 */

int cx_vr_video_close(void *hdl, int fd);	/* 关闭录像文件 */

int cx_vr_video_seek(void *hdl, int fd, uint32_t time_stamp);	/* SEEK文件到指定时间戳 */

int cx_vr_start_stmanager(void *hdl);

/** @} */

#ifdef __cplusplus
}
#endif

#endif /* CX_RECORD_H */

